using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE;
using EnvDTE80;
using Koda.VisualStudio;
using Koda.UI;
using Koda.VisualStudio.Integration;

namespace Koda.Commands
{
    public class CodeOutlineCommand : VsCommand
    {
        private Window codeOutlineToolWindow;

        public CodeOutlineCommand() : base("Code Outline", "MenuBar.Tools", 1)
        {
        }

        public override void OnExecute(VsCommandEventArgs e)
        {
            if (this.codeOutlineToolWindow == null)
            {
                object temp = null;
                Windows2 windows = (Windows2)e.DTE.Windows;
                this.codeOutlineToolWindow = windows.CreateToolWindow2(e.AddIn, System.Reflection.Assembly.GetExecutingAssembly().Location, "Koda.UI.CodeOutlineView", "Code Outline", "{786FD1AF-97BA-4f44-B73C-021FA6E174BC}", ref temp);

                CodeOutlineView codeOutlineView = (CodeOutlineView)temp;
                codeOutlineView.DTE = e.DTE;
                codeOutlineView.ParentWindow = this.codeOutlineToolWindow;

                this.codeOutlineToolWindow.Visible = true;
            }
            else
            {
                this.codeOutlineToolWindow.Activate();
            }
        }
    }
}